package com.ls.markt.service.admin;

import com.ls.markt.model.admin.Resources;
import com.ls.markt.repository.admin.ResourcesRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ResourcesServirce {

    @Resource
    ResourcesRepository resourceRepository;

    public List<Resources> findAll(){
        return resourceRepository.findAll();
    }

    /**
     * 分页 查询全部
     * @param pageRequest
     * @return
     */
    public Page<Resources> findAll(PageRequest pageRequest){
        return resourceRepository.findAll(pageRequest);
    }

    public Resources getResourcesById(Long id){
        return resourceRepository.getOne(id);
    }

    public void saveResources(Resources resources){
        resourceRepository.save(resources);
    }

    public void removeResources(Long[] ids){
        for (Long id: ids) {
            resourceRepository.deleteById(id);
        }
    }

}
